package com.cui.wuye.controller;

import com.cui.wuye.entity.Shop;
import com.cui.wuye.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
//json字符串注解
@RestController

public class ShopController {

    @Autowired
    ShopService shopService;


    @RequestMapping("selectShopfindAll")
    public List<Shop> selectShopfindAll(Shop shop){
        List<Shop> shopLists = shopService.selectShopfindAll(shop);
        return shopLists;
    }

    //通过id删除
    @RequestMapping("deleteShop")
    public String deleteBookById( Long sid){
        try {
            shopService.deleteShop( sid );
            return "success";
        } catch (Exception e) {
            e.printStackTrace();
            return "fail";
        }
    }

    @RequestMapping("addShop")
    public Shop addShop(Shop shop){
        shopService.addShop( shop );
        return shop;
    }

    @RequestMapping("updateShop")
    public Shop updateShop(Shop shop){
        shopService.updateShop( shop );
        return shop;
    }
}
